﻿using System;
using System.Collections;

namespace GenericityStudy
{

    //泛型类
    class Base<T, U> {
        T a;
        //无参构造函数
        public Base() { 
        
        }
        //有参构造函数
        public Base(T a) {
            this.a = a;
        }
        //泛型成员变量a的属性
        public T A
        {
            get {
                return this.a;
            }
            set {
                this.a = value;
            }
        }

        class Child:Base<T,U> {
        
        }

        //注意这不是泛型方法（它的参数类型在定义类时就会被确定类型）
        public void setA(U u) {
            Console.WriteLine(u);
        }
        //定义泛型方法
        public void setGenericity<T>(){
            T index = default(T);
            Console.WriteLine(index);
        }

    }

    interface IBase<T, U> {
        public void setTU(T t,U u)
        {
            Console.WriteLine(t+"  "+u);
        }
    }

    class Program
    {
        static void Main1(string[] args)
        {
            //ArrayList list = new ArrayList();
            //list.Add('l');
            //list.Add(44);
            Base<string,int> base1 = new Base<string,int>("aaaaaa");
            Console.WriteLine("泛型成员变量a属性： "+base1.A);
            base1.setA(666);
            base1.setGenericity<int>();
            Console.WriteLine("====================");

            

        }
    }
}
